<template>
  <div class="pagebox">
    <crumbs @goBack="goBack" :superiorMenu="['技术管理']" currentMenu="工艺路线" style="margin-bottom: 12px"></crumbs>
    <a-card :bordered="false" size="small">
      <div class="topBox">
        <div>
          <a-button @click="handleShowFilter" icon="filter"
            >筛选 <span class="filter-num" style="margin-left: 5px">{{ ' ' + filteredNums() }}</span></a-button
          >
          <a-button @click="showColumn" icon="unordered-list" style="margin-left: 10px"> 设置列 </a-button>
        </div>
        <div class="right-btn">
          <PubImport
            @updateParentData="updateParentData"
            ref="PubImport"
            formType="9"
            modelName="工艺路线导入模板"
            style="margin-right: 10px"
            v-if="hasButton('processRoute:import')"
          />
          <PubExport
            :exportUrl="exportUrl"
            :columns="columns"
            :propForm="formatData()"
            :selectedRows="selectedRows"
            :sortForm="sortForm"
            :fullName="fullName"
            v-if="hasButton('processRoute:derived')"
          />
          <a-button type="primary" @click="add" class="btns" v-if="hasButton('processRoute:add')"> +新建 </a-button>
        </div>
      </div>
      <a-table
        row-key="id"
        :key="tableKey"
        :columns="columns"
        :data-source="tableData"
        :pagination="false"
        :scroll="{ x: scrollX, y: 'calc(100vh - 300px)' }"
        :row-selection="{ selectedRowKeys: selectedRowKeys, columnTitle: ' ', onChange: onSelectChange }"
        @change="handleChange"
        :components="drag(columns, 'PROCESS_ROUTE_LIST')"
      >
        <span :title="text" slot="craftName" slot-scope="text">
          {{ text }}
        </span>
        <span :title="text" slot="remark" slot-scope="text">
          {{ text }}
        </span>
        <!-- 输入框搜索 -->
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <a-input
            placeholder="请输入"
            v-model="filterForm[column.dataIndex]"
            style="width: 188px; display: block"
            @pressEnter="handleSearch"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <div slot="updateByInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <j-select-user-by-dep
            v-model="filterForm[`${column.dataIndex}`]"
            :multi="true"
            @changeRow="(a, b, c) => onChangeUser(b || {}, 'updateBy')"
          ></j-select-user-by-dep>

          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <div slot="createByInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <j-select-user-by-dep
            v-model="filterForm[`${column.dataIndex}`]"
            :multi="true"
            @changeRow="(a, b, c) => onChangeUser(b || {}, 'createBy')"
          ></j-select-user-by-dep>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="searchIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <a-icon
          slot="dateIcon"
          slot-scope="filtered"
          type="filter"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <span slot="craftCode" slot-scope="text, record" class="btn-text" @click="handleDetail(record)">
          {{ record.craftCode }}
        </span>
        <span slot="action" slot-scope="text, record">
          <a-button type="link" style="width: 42px" @click="handleEdit(record)" v-if="hasButton('processRoute:edit')">编辑</a-button>
          <a-divider type="vertical" v-if="(hasButton('processRoute:copy') || hasButton('processRoute:delete')) && hasButton('processRoute:edit')" />
          <a-dropdown>
            <a class="ant-dropdown-link" v-if="hasButton('processRoute:copy') || hasButton('processRoute:delete')">
              更多
              <a-icon type="down" />
            </a>
            <a-menu slot="overlay">
              <!-- <a-menu-item>
                <a-button type="link" @click="printIt(record.id, true)">打印</a-button>
              </a-menu-item> -->
              <a-menu-item>
                <a-button type="link" @click="copyIt(record)" v-if="hasButton('processRoute:copy')">复制</a-button>
              </a-menu-item>
              <a-menu-item>
                <a-button style="color: #f25643; margin-top: 2px" type="link" @click="handleDelete(record)" v-if="hasButton('processRoute:delete')">
                  删除</a-button
                >
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </a-card>
    <div class="uni-card pagination-contian" :style="{ left: collapsed ? '219px' : '90px' }">
      <div class="check-contain">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <!-- <span class="pubColor" style="margin: 0 24px">批量完成</span><span class="pubColor">批量作废</span> -->
        <span style="margin-left: 8px">
          <span @click="handleDelete(selectedRowKeys)" class="pubColor" style="margin: 0 10px" v-if="hasButton('processRoute:delete')">删除</span>
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }}
          <span @click="clearArr" class="pubColor" style="margin: 0 10px">清空</span>
        </span>
      </div>
      <div class="page-contain">
        <a-pagination
          :total="total"
          v-model="current"
          :page-size-options="pageSizeOptions"
          :page-size="pageSize"
          @change="onChangePage"
          @showSizeChange="onShowSizeChange"
          show-quick-jumper
          show-size-changer
        />
      </div>
    </div>
    <SetColumn
      columnName="设置列"
      ref="SetColumn"
      v-if="showSetColumn"
      @sureBtn="sureBtn"
      @cancelBtn="showSetColumn = false"
    />
    <a-drawer placement="right" width="500" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums(1) }}</span>
        </div>
        <div v-if="filteredNums(1) > 0" class="tagContian">
          <div v-for="(item, i) in filteredList" :key="i" v-show="'' + item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="工艺编号">
                <a-input v-model="filterForm.processRouteCode" placeholder="请输入" :maxLength="30" />
              </a-form-model-item>
              <a-form-model-item label="工艺名称">
                <a-input v-model="filterForm.processRouteName" placeholder="请输入" :maxLength="30" />
              </a-form-model-item>
              <a-form-model-item label="创建人">
                <j-select-user-by-dep
                  @changeRow="(a, b, c) => onChangeUser(b || {}, 'createBy')"
                  v-model="filterForm.createBy"
                  :seldep="true"
                  :modalWidth="1000"
                  :limit="5"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="更新人">
                <j-select-user-by-dep
                  @changeRow="(a, b, c) => onChangeUser(b || {}, 'updateBy')"
                  v-model="filterForm.updateBy"
                  :seldep="true"
                  :modalWidth="1000"
                  :limit="5"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="更新时间">
                <a-range-picker
                  date-format="YYYY-MM-DD"
                  :placeholder="['请输入', '请输入']"
                  v-model="filterForm.updateTime"
                  style="width: 100%"
                  @change="(a, b) => timeChange(a, b, 'updateTime')"
                />
              </a-form-model-item>
              <a-form-model-item label="创建时间">
                <a-range-picker
                  date-format="YYYY-MM-DD"
                  :placeholder="['请输入', '请输入']"
                  v-model="filterForm.createTime"
                  style="width: 100%"
                  @change="(a, b) => timeChange(a, b, 'createTime')"
                />
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <windowForm ref="windowForm" @refresh="handleSearch"></windowForm>
    <windowDetail ref="windowDetail"></windowDetail>
  </div>
</template>
<script>
import {
  VALIDATE_NO_PASSED,
  FormTypes,
  getRefPromise,
  validateFormAndTables,
  validateTables,
} from '@/utils/JEditableTableUtil'
import { getAction, httpAction, deleteAction } from '@/api/manage'
import SetColumn from '@/pubComponent/SetColumn.vue'
import { getNewColumns, numFormat, subStrText, camelCase2UnderLine } from '@/utils/util'
import {
  basicProcessRouteInfoList,
  basicProcessRouteInfoDelete,
  basicProcessRouteInfoDeleteBatch,
} from '@/api/goodsManagement'
import FileUpload from '@/components/fileActions/FileUpload.vue'
import crumbs from '@/components/crumbs.vue'
import { mapState } from 'vuex'
import tableDragResize from '@/mixins/tableDragResize'
import windowDetail from './processRouteDetail.vue'
import windowForm from './processRouteForm.vue'
import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep.vue'
import PubImport from '@/components/pubBtn/PubImport.vue'
import PubExport from '@/components/pubBtn/PubExport.vue'
import moment from 'moment'
import { hasButton } from '@/utils/hasPermission'

// 表头
/* 打开设置列面板123 */
const columnsValue = [
  {
    title: '工艺编号',
    dataIndex: 'processRouteCode',
    key: 'processRouteCode',
    width: 160,
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'processRouteCode',
    },
  },
  {
    title: '工艺名称',
    dataIndex: 'processRouteName',
    key: 'processRouteName',
    width: 160,
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'processRouteName',
    },
  },
  {
    title: '工序',
    dataIndex: 'processesName',
    width: 160,
    key: 'processesName',
    ellipsis: true,
    scopedSlots: {},
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    sorter: true,
    width: 160,
    key: 'createTime',
    ellipsis: true,
    scopedSlots: {},
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    sorter: true,
    width: 160,
    key: 'updateTime',
    ellipsis: true,
    scopedSlots: {},
  },
  {
    title: '创建人',
    dataIndex: 'createBy',
    ellipsis: true,
    width: 180,
    searchIndex: 'createBy',
    options: [],
    scopedSlots: {
      filterDropdown: 'createByInput',
      filterIcon: 'dateIcon',
      customRender: 'createBy',
    },
  },
  {
    title: '更新人',
    dataIndex: 'updateBy',
    ellipsis: true,
    width: 180,
    searchIndex: 'updateBy',
    options: [],
    scopedSlots: {
      filterDropdown: 'updateByInput',
      filterIcon: 'dateIcon',
      customRender: 'updateBy',
    },
  },
]
const actionArr = [
  {
    fixed: 'right',
    title: '操作',
    dataIndex: 'action',
    width: 180,
    align: 'left',
    scopedSlots: { customRender: 'action' },
  },
]
export default {
  name: 'teamManagementList', //班组管理列表
  components: { crumbs, SetColumn, windowDetail, windowForm, JSelectUserByDep, PubImport, PubExport },
  mixins: [tableDragResize],
  data() {
    return {
      subStrText,
      numFormat,
      columns: [
        {
          title: '工艺编号',
          dataIndex: 'processRouteCode',
          key: 'processRouteCode',
          width: 160,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'processRouteCode',
          },
        },
        {
          title: '工艺名称',
          dataIndex: 'processRouteName',
          key: 'processRouteName',
          width: 160,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'processRouteName',
          },
        },
        {
          title: '工序',
          dataIndex: 'processesName',
          width: 160,
          key: 'processesName',
          ellipsis: true,
          scopedSlots: {},
        },
        {
          title: '创建时间',
          dataIndex: 'createTime',
          sorter: true,
          width: 160,

          key: 'createTime',
          ellipsis: true,
          scopedSlots: {},
        },
        {
          title: '更新时间',
          dataIndex: 'updateTime',
          sorter: true,
          width: 160,
          key: 'updateTime',
          ellipsis: true,
          scopedSlots: {},
        },
        {
          title: '创建人',
          dataIndex: 'createBy',
          ellipsis: true,
          width: 180,
          searchIndex: 'createBy',
          options: [],
          scopedSlots: {
            filterDropdown: 'createByInput',
            filterIcon: 'dateIcon',
            customRender: 'createBy',
          },
        },
        {
          title: '更新人',
          dataIndex: 'updateBy',
          ellipsis: true,
          width: 180,
          searchIndex: 'updateBy',
          options: [],
          scopedSlots: {
            filterDropdown: 'updateByInput',
            filterIcon: 'dateIcon',
            customRender: 'updateBy',
          },
        },
      ],
      exportUrl: '/basicprocess/basicProcessRouteInfo/exportRouteXls',
      fullName: `工艺路线 ${moment(new Date()).format('YYYY-MM-DD HH:mm')}`,
      tableData: [],
      selectedRowKeys: [],
      selectArr: [],
      //全选按钮
      listIndeterminate: false,
      listCheckAll: false,
      showFilter: false, // 筛选抽屉
      // 筛选form
      filterForm: {
        processRouteCode: '', //工艺编号
        processRouteName: '', //工艺名称
        createBy: '', //物料名称
        updateBy: '', //物料名称
        updateTime: [],
        updateTimeBegin: '',
        updateTimeEnd: '',
        createTime: [],
        createTimeBegin: '',
        createTimeEnd: '',
      },
      filteredFormLable: {
        processRouteCode: '工艺编号', //工序编号
        processRouteName: '工艺名称', //工序名称
        updateTime: '更新时间', //物料名称
        createBy: '创建人', //物料名称
        updateBy: '更新人', //物料名称
        spec: '规格',
        createTime: '创建时间',
      },
      // 分页
      current: 1,
      total: 0,
      pageSize: 30,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      // 排序
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      showSetColumn: false,
      tableKey: 1.9,
      sessionParams: {},
      showCreateStr: '',
      showUpdateStr: '',
      selectedRows: [],
    }
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsedAno,
    }),
    hasSelected() {
      return this.selectedRowKeys.length > 0
    },
    filteredList() {
      let list = []
      for (let key in this.filterForm) {
        if (key == 'updateTimeBegin' || key == 'updateTimeEnd' || key == 'createTimeBegin' || key == 'createTimeEnd') {
        } else if (key == 'createBy') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showCreateStr,
            key,
          })
        } else if (key == 'updateBy') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showUpdateStr,
            key,
          })
        } else if (key == 'updateTime' && this.filterForm[key].length != 0) {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm['updateTimeBegin'] + '~' + this.filterForm['updateTimeEnd'],
            key,
          })
        } else if (key == 'createTime' && this.filterForm[key].length != 0) {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm['createTimeBegin'] + '~' + this.filterForm['createTimeEnd'],
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      return list
    },
  },
  created() {
    // this.$store.commit('SET_CURRENT_PREFIX', '/jksaas-easyMake/easyMake')

    let sessionObj = sessionStorage.getItem(`${this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST}filter`)
    if (sessionObj) {
      let obj = JSON.parse(sessionObj)
      // this.filterForm = obj.filterForm
      this.sortForm = obj.sortForm
      this.current = obj.current
      this.pageSize = obj.pageSize
    }
    this.initData()
    this.requestData()
  },
  beforeRouteLeave(to, from, next) {
    if (to.path != '/skillManagement/processRoute/processRouteForm' || JSON.stringify(to.query) == '{}') {
      sessionStorage.removeItem(`${this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST}filter`)
    }
    next()
  },
  methods: {
    hasButton,
    //导入
    updateParentData() {
      let params = this.formatData()
      this.current = 1
      let obj = {
        pageNo: this.current,
        pageSize: this.pageSize,
        ...params,
      }
      this.requestData()
    },
    // 筛选传参数据
    formatData() {
      let parameter = {
        ...this.filterForm,
        pageNo: this.current,
        pageSize: this.pageSize,
        ...this.sortForm,
      }
      return parameter
    },
    // 时间选择器回调
    timeChange(a, b, key) {
      if (a.length == 0) {
        this.filterForm[`${key}Begin`] = ''
        this.filterForm[`${key}End`] = ''
        this.filterForm[key] = []
        return
      }
      this.filterForm[`${key}Begin`] = b[0]
      this.filterForm[`${key}End`] = b[1]
      this.filterForm[key] = b
    },
    // 创建人
    // createChange(storeVals, row, userIndex) {
    //   if (row.length > 0) {
    //     let newArr = []
    //     let arrTwo = []
    //     for (let item of row) {
    //       newArr.push(item.id)
    //       arrTwo.push(item.realname)
    //     }
    //     if (arrTwo.length > 0) {
    //       this.showCreateStr = arrTwo.join(',')
    //     }
    //   } else {
    //     this.showCreateStr = ''
    //   }
    // },
    // 人员筛选回调
    onChangeUser(row, index) {
      if (row.length > 0) {
        let arrTwo = []
        for (let item of row) {
          arrTwo.push(item.realname)
        }
        if (arrTwo.length > 0) {
          this[index == 'updateBy' ? 'showUpdateStr' : 'showCreateStr'] = arrTwo.join(',')
        }
      } else {
        this[index == 'updateBy' ? 'showUpdateStr' : 'showCreateStr'] = ''
      }
    },
    // 更新人
    // updateChange(storeVals, row, userIndex) {
    //   if (row.length > 0) {
    //     let newArr = []
    //     let arrTwo = []
    //     for (let item of row) {
    //       newArr.push(item.id)
    //       arrTwo.push(item.realname)
    //     }
    //     if (arrTwo.length > 0) {
    //       this.showUpdateStr = arrTwo.join(',')
    //     }
    //   } else {
    //     this.showUpdateStr = ''
    //   }
    // },
    /* 删除、批量删除 */
    handleDelete(v) {
      if (v instanceof Array) {
        if (v.length > 0) {
          let that = this
          that.$antdConfirm({
            title: '确定要删除工艺吗?',
            content: `删除后不可恢复！`,
            onOk() {
              basicProcessRouteInfoDeleteBatch({ ids: v.toString() }).then((res) => {
                if (res.code == 200) {
                  that.$antdMessage.success('删除成功！')
                  that.handleSearch()
                  that.clearArr()
                } else {
                  that.$antdMessage.error('删除失败！')
                }
              })
            },
            onCancel() {},
          })
        } else {
          this.$antdMessage.warning('请勾选需要批量删除的数据')
        }
      } else {
        let that = this
        that.$antdConfirm({
          title: '确定删除工艺吗?',
          content: `删除后不可恢复！`,
          onOk() {
            basicProcessRouteInfoDelete({ id: v.id }).then((res) => {
              if (res.code == 200) {
                that.$antdMessage.success('删除成功！')
                if (that.tableData.length === 1) {
                  that.current = that.current == 1 ? 1 : that.current - 1
                }
                that.requestData()
                that.clearArr()
              } else {
                that.$antdMessage.error('删除失败！')
              }
            })
          },
          onCancel() {},
        })
      }
    },
    /* 编辑 */
    handleEdit(v) {
      sessionStorage.setItem(`${this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST}filter`, JSON.stringify(this.sessionParams))

      this.$refs.windowForm.initForm(v.id)
    },
    copyIt(v) {
      this.$refs.windowForm.initForm(v.id, true)
    },
    // 详情
    handleDetail(v) {
      this.$refs.windowDetail.initDetail(v.id)
    },
    // 加载数据
    initData() {
      /* 设置列 */
      var oldValue = localStorage.getItem(this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST)
      this.columns = getNewColumns(columnsValue, JSON.parse(oldValue), actionArr, this.columns)
    },
    requestData() {
      let filterFormAno = JSON.parse(JSON.stringify(this.filterForm))
      if (filterFormAno.updateTime && filterFormAno.updateTime.length == 2) {
        filterFormAno.updateTimeBegin = filterFormAno.updateTime[0] + ' 00:00:00'
        filterFormAno.updateTimeEnd = filterFormAno.updateTime[1] + ' 23:59:59'
        delete filterFormAno.updateTime
      }
      if (filterFormAno.createTime && filterFormAno.createTime.length == 2) {
        filterFormAno.createTimeBegin = filterFormAno.createTime[0] + ' 00:00:00'
        filterFormAno.createTimeEnd = filterFormAno.createTime[1] + ' 23:59:59'
        delete filterFormAno.createTime
      }
      /* 请求列表数据 */
      let parameter = {
        ...filterFormAno,
        pageNo: this.current,
        pageSize: this.pageSize,
        ...this.sortForm,
      }
      this.sessionParams = {
        filterForm: filterFormAno,
        sortForm: this.sortForm,
        current: this.current,
        pageSize: this.pageSize,
      }
      basicProcessRouteInfoList(parameter).then((res) => {
        if (res.code == 200) {
          this.tableData = res.result.records
          this.total = res.result.total
        }
      })
    },
    // 导航栏
    goBack() {},
    // 点击新建按钮
    add() {
      this.$refs.windowForm.initForm()
    },
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      // confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥00：', selectedKeys)
      // console.log('这都是啥11：', confirm)
      // console.log('这都是啥22：', dataIndex)
      // console.log('这都是啥33：', clearFilters)
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.handleSearch()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      if (key == 'createBy') {
        this.showCreateStr = ''
      } else if (key == 'updateBy') {
        this.showUpdateStr = ''
      } else if (key == 'createTime' || key == 'updateTime') {
        this.filterForm[`${key}Begin`] = ''
        this.filterForm[`${key}End`] = ''
        this.filterForm[key] = []
        return
      }
      this.filterForm[key] = ''
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        processRouteCode: '', //工艺编号
        processRouteName: '', //工艺名称
        createBy: '', //物料名称
        updateBy: '', //物料名称
        updateTime: [],
        updateTimeBegin: '',
        updateTimeEnd: '',
        createTime: [],
        createTimeBegin: '',
        createTimeEnd: '',
      }
      this.showCreateStr = ''
      this.showUpdateStr = ''
      // this.showFilter = false
      this.handleSearch()
    },
    filteredNums(n) {
      let nums = 0
      if (n) {
        for (let key in this.filterForm) {
          if (
            this.filterForm[key] != '' &&
            key != 'updateTimeBegin' &&
            key != 'updateTimeEnd' &&
            key != 'createTimeBegin' &&
            key != 'createTimeEnd'
          ) {
            nums += 1
          }
        }
      } else {
        for (let key in this.filterForm) {
          if (
            this.filterForm[key] != '' &&
            key != 'updateTimeBegin' &&
            key != 'updateTimeEnd' &&
            key != 'createTimeBegin' &&
            key != 'createTimeEnd'
          ) {
            nums += 1
          }
        }
      }
      return nums
    },
    /* 打开设置列面板123 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(columnsValue, this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumns(columnsValue, emitArr, actionArr)
      localStorage.setItem(this.BUSI_CONST.Entity.PROCESS_ROUTE_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    // table
    // 排序
    handleChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: camelCase2UnderLine(sorter.columnKey),
        }
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.requestData()
      }
    },
    // table选择
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRows = selectedRows
      this.selectedRowKeys = selectedRowKeys
      this.checkBoxStatus()
    },
    // 全选
    onCheckAllChange(e) {
      if (e.target.checked) {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
          this.selectedRowKeys.push(item.id)
        }
      } else {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
        }
      }
      this.checkBoxStatus()
    },
    // 清空
    clearArr() {
      this.selectedRowKeys = []
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.tableData) {
          tableIds.push(item.id)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.requestData()
    },
    onShowSizeChange(current, pageSize) {
      this.pageSize = pageSize
      this.current = current
      this.requestData()
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.table-operations {
  margin-bottom: 16px;
}

.table-operations > button {
  margin-right: 8px;
}
.topBox {
  .flex(space-between, center);
  margin-bottom: 16px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
// /deep/.ant-btn {
//   width: 42px;
// }
.pubColor {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}
.pagebox {
  /deep/ .ant-card-body {
    height: calc(100vh - 174px);
    overflow: hidden;
    padding: 20px 16px;
  }
}
.header {
  width: 150%;
  margin: -12px -12px @distance4;
}
.backBox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .backC {
    cursor: pointer;
    display: flex;
    align-items: center;
  }
}
.j-table-force-nowrap {
  margin-top: @distance1;
}
.btns {
  margin-left: @distance5;
}
.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
.mg-left {
  margin-left: @distance3;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.tagContian {
  background: #fff;
  display: flex;
  justify-content: start;
  flex-wrap: wrap;
  padding: 10px 20px;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap {
  margin: 10px 0 0 10px;
}
</style>
